package com.CS3340.project;

public class Player {
	
	private int funds; // funds per player
	//probably create an array of cards for the hand - Bikas
	private card[] currHand;
	
	public Player() {
		//constructor to initialize variables
		funds = 100; //can change later
		currHand = new card[5];
	}
	
	public void getDealt(card[] hand) {
		currHand = new card[5];
		currHand = hand;
	}
	
	// might not need this function
	public card[] showHand()
	{
		// return Current Hand
		return currHand;
	}
		
	public int displayFunds()
	{
		// Return Current Player's funds
		return funds;
	}
	
	// set the current hand to 0.
	public void fold()
	{
		// Fold current round
		// Delete currHand;
		// However, JAVA doesn't support "delete"?
		currHand = null;
	}
		
	public void call()
	{
			// Call the bet
		//
	}
		
	// bet() takes an argument betAmount, which should be a FIXED
	// size from the GameManager.
	public int bet(int betAmount)
	{
		int contribution;
		
		// Base Case: Player is no longer in the game
		// just return 0.
		if (funds == 0)
			return 0;
		
		// Base Case: Handle "all in"
		if (betAmount > funds){
			contribution = funds;
			funds = 0; // player's funds is reduced to 0.
		}
		else {
			contribution = betAmount;
			funds -= betAmount; // reduce Player's funds
		}
		
		
		return contribution; // Add contribution to the running total/"pot"
	}
	
	public void winFunds(int amount) {
		funds += amount;
	}
		
	public void exchange(int pos, card toExchange)
	{ 
		currHand[pos] = toExchange;
		/*card[] choice;
		boolean exchange = false;
		// Player exchanges up to 3 cards with the dealer.
		while (exchange)
		{
			// Pick up to 3 cards
			// switch exchange
			// then pop from the deck = amount of cards to exchange
			// return true
			// else nothing pop
			// return true
			/*
			switch(choice){
			case currHand[0]:
			case currHand[1]:
			case currHand[2]:
			case currHand[3]:
			case currHand[4]:
			default:
				exchange = true; // nothing was exchanged
				break;
				
			}*/
		}
	}

